import Vue from 'vue'
import App from './App.vue'
import wg_form from './wg-form.vue'
import router from './router'
import store from './store'
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import ajax from './publicJS/ajax'
import W from './publicJS/WG'

Vue.prototype.$ajax = ajax
Vue.prototype.$w = W
Vue.use(Element)
Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  if (from.name) { // 当路由有跳转时 在进行拦截
    let matchrol = store.state.matchrole
    let to_path = to.path
    let resulet = matchrol.find(el => {
      return el.path == to_path
    })
    console.log('路由匹配结果', resulet)
    if (resulet) {
      next()
    } else {
      next({
        path: from.path
        
      })
    }

  } else {
    next()

  }


})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')


var title = document.getElementsByTagName('title')[0]
console.log("title", title.innerHTML = '湖南省交通运输规划项目库系统管理')